package com.tupu.service.impl.dispatch;

import cn.hutool.core.date.DateUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tupu.entity.dispatch.DadsCzp;
import com.tupu.entity.dispatch.DispatchPlannedOperTicket;
import com.tupu.mapper.dispatch.*;
import com.tupu.service.dispatch.OperTicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;


@Service
public class OperTicketServiceImpl extends ServiceImpl<DispatchPlannedOperTicketMapper, DispatchPlannedOperTicket> implements OperTicketService {

    @Autowired(required = false)
    private DispatchPlannedOperTicketMapper dispatchPlannedOperTicketMapper;

    @Autowired(required = false)
    private DispatchOperTicketDetailsMapper dispatchOperTicketDetailsMapper;

    @Autowired(required = false)
    private DispatchOperTicketPerformMsgMapper dispatchOperTicketPerformMsgMapper;

    @Autowired
    private DadsDdrzMapper dadsDdrzMapper;

    @Override
    @DS("dfdz")
    public Page<DispatchPlannedOperTicket> findAll(Long page, Long size, String station_name) {
        Page pageInfo = new Page();
        pageInfo.setSize(size);
        pageInfo.setCurrent(page);
        String startDate = DateUtil.formatDateTime(DateUtil.beginOfDay(new Date()));
        Date date = DateUtil.offsetDay(new Date(), 3);
        String endDate = DateUtil.formatDateTime(DateUtil.endOfDay(date));
        Page<DispatchPlannedOperTicket> plannedOperTicketPage = dadsDdrzMapper.getDadsCzp(pageInfo, station_name, startDate, endDate);
        return plannedOperTicketPage;
    }
}

